package com.chen.service.Impl;

import com.chen.mapper.EmpMapper;
import com.chen.mapper.StudentMapper;
import com.chen.pojo.JobOption;
import com.chen.pojo.StudentOption;
import com.chen.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private EmpMapper empMapper;
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public JobOption getJobData() {
        //1. 查询员工职位数据
        List<Map<String,Object>> list = empMapper.countEmpJobData();
        //2. 封装数据
        List<Object> jobList = list.stream().map(dataMap -> dataMap.get("job")).toList();
        List<Object> dataList = list.stream().map(dataMap -> dataMap.get("num")).toList();
        return new JobOption(jobList,dataList);
    }

    @Override
    public List<Map<String, Object>> getEmpGenderData() {
        return  empMapper.countEmpGenderData();

    }

    @Override
    public List<Map<String, Object>> getStudentDegreeData() {
        return studentMapper.countStudentDegreeData();
    }

    @Override
    public StudentOption getStudentCountData() {
        List<Map<String,Object>> data =studentMapper.getStudentCountData();
        List<Object> clazzList = data.stream().map(dataMap -> dataMap.get("name")).toList();
        List<Object> dataList = data.stream().map(dataMap -> dataMap.get("value")).toList();
        return new StudentOption(clazzList,dataList);
    }

}
